package com.jt;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
public class ConsumerApplication {
    public static void main(String[] args) {
        SpringApplication.run(ConsumerApplication.class, args);
    }
    @Bean
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }
    @RestController
    public class ConsumerController{
        @Value("${spring.application.name}")
        private String name;
        @Autowired
        private RestTemplate restTemplate; 
        @GetMapping("/consumer/doRestEcho2")
        public String doRestEcho02(){
            String url="http://localhost:8081/provider/echo/"+name;
            return restTemplate.getForObject(url,String.class );
        }
    }
}
